package com.freemarker.demo;

import java.io.File;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.util.HashMap;
import java.util.Map;

import freemarker.template.Configuration;
import freemarker.template.Template;

public class Test1 {
	public static void main(String[] args) throws Exception {
		Configuration cfg = new Configuration();
		cfg.setDirectoryForTemplateLoading(new File("templates"));
		
		Map root = new HashMap();
		root.put("user", "呵呵呵");
		
		Template t = cfg.getTemplate("a.ftl");
		
		Writer out = new OutputStreamWriter(System.out);
		t.process(root, out);
		out.flush();
	}
}
